package notes;

import interfaces.Noteable;

public class Note implements Noteable {

	private String title;
	private String text;
	private String time;
	
	public static Note createNewNote(String title, String text, String time) {
		Note note = new Note(title, text, time);
		if(note.getText() != null && note.getTitle() != null) {
			return note;
		}
		
		return null;
	}
	
	protected Note(String title, String text, String time) {
		setNewTitle(title);
		setNewText(text);
		this.time = time;
	}
	
	@Override
	public String getTitle() {
		return title;
	}
	
	@Override
	public String getText() {
		return text;
	}
	
	@Override
	public boolean setNewTitle(String title) {
		if(title != null && title != "") {
			this.title = title;
			return true;
		}
		
		return false;
	}
	
	@Override
	public boolean setNewText(String text) {
		if(text != null) {
			this.text = text;
			return true;
		}
		
		return false;
	}
	
	@Override
	public boolean equals(Object o) {
		if(o instanceof Note) 
			return (getText() + getTitle()) == ((((Note) o).getText() + ((Note) o).getTitle()));
		else 
			return false;
	}

	@Override
	public String getTime() {
		return time;
	}
	
}
